<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>恢复之前定义过的异常处理函数。</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.restore-exception-handler" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">restore_exception_handler</h1>
  <p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">restore_exception_handler</span> &mdash; <span class="dc-title">
   恢复之前定义过的异常处理函数。
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.restore-exception-handler-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>restore_exception_handler</strong></span>
    ( <span class="methodparam">void</span>
   ) : <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   在使用 <span class="function"><a href="set_exception_handler.html" class="function">set_exception_handler()</a></span> 改变异常处理函数之后，此函数可以
   用于还原之前的异常处理程序(可以是内置的或者也可以是用户所定义的函数)。
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.restore-exception-handler-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   该函数总是返回 <strong><code>TRUE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.restore-exception-handler-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-463">
    <p><strong>Example #1 <span class="function"><strong>restore_exception_handler()</strong></span> 范例</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">exception_handler_1</span><span style="color: #007700">(</span><span style="color: #0000BB">Exception&nbsp;$e</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'['&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">__FUNCTION__&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">']&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getMessage</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">exception_handler_2</span><span style="color: #007700">(</span><span style="color: #0000BB">Exception&nbsp;$e</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'['&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">__FUNCTION__&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">']&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getMessage</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">set_exception_handler</span><span style="color: #007700">(</span><span style="color: #DD0000">'exception_handler_1'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">set_exception_handler</span><span style="color: #007700">(</span><span style="color: #DD0000">'exception_handler_2'</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">restore_exception_handler</span><span style="color: #007700">();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;</span><span style="color: #0000BB">Exception</span><span style="color: #007700">(</span><span style="color: #DD0000">'This&nbsp;triggers&nbsp;the&nbsp;first&nbsp;exception&nbsp;handler...'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
[exception_handler_1] This triggers the first exception handler...
</pre></div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.restore-exception-handler-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="set_exception_handler.html" class="function" rel="rdfs-seeAlso">set_exception_handler()</a> - 设置用户自定义的异常处理函数</span></li>
    <li class="member"><span class="function"><a href="set_error_handler.html" class="function" rel="rdfs-seeAlso">set_error_handler()</a> - 设置用户自定义的错误处理函数</span></li>
    <li class="member"><span class="function"><a href="restore_error_handler.html" class="function" rel="rdfs-seeAlso">restore_error_handler()</a> - 还原之前的错误处理函数</span></li>
    <li class="member"><span class="function"><a href="error_reporting.html" class="function" rel="rdfs-seeAlso">error_reporting()</a> - 设置应该报告何种 PHP 错误</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>